﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.TeamFoundation.VersionControl.Client;
using PsTFS.Objects;

namespace PsTFS.Methodes
{
    /// <summary>
    /// Classe de gestion du workspace
    /// </summary>
    public static partial class Methode
    {
        /// <summary>
        /// Permet de récupérer l'ensemble des workspace
        /// </summary>
        /// <returns></returns>
        public static List<Workspace> GetAllWorkspaces(string owner, bool localOnly)
        {
            // Récupération du Version Control. 
            var versionControl = MethodService.VersionControlServer();
            var ws = versionControl.QueryWorkspaces(null,
                                                    !string.IsNullOrEmpty(owner) ? owner : null,
                                                    localOnly ? Environment.MachineName : null);
            return new List<Workspace>(ws);
        }

        public static List<Workspace> GetAllWorkspaces(bool localOnly)
        {
            return GetAllWorkspaces(null, localOnly);
        }
    }
}
